package com.MP_fianl;

import java.io.File;
import java.io.IOException;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.VideoView;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.pm.ActivityInfo;

public class MP_final_content extends Activity {
	
	private ImageButton mImageButton1;
	private ImageButton mImageButton2;
	private ImageButton mImageButton3;
	private ImageButton mImageButton4;
	private ImageButton mImageButton5;
	
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.content);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        handle_ImageButton();
       
  }
  
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
        if (keyCode == KeyEvent.KEYCODE_BACK) {         	
        	showDialogue("Leave Suit Yourself?");
        	//return super.onKeyDown(keyCode, event);
        }
        return false;
    }
    
    public void showDialogue(String msg)
    {
    	//alert dialogue
    	new AlertDialog.Builder(MP_final_content.this)
        .setTitle("Alert")
        .setMessage(msg)
        .setIcon(R.drawable.bells64) 
        .setPositiveButton
        (
        		R.string.str_ok,
        		new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						/*ComponentName tolauch = new ComponentName("com.htc.flash","com.htc.flash.FlashPlayer");
						if(tolauch != null)
						{
							//Intent intent = new Intent(Intent.ACTION_MAIN);
							File file = new File("/sdcard/s022_snoopydance.swf");
							Intent intent = new Intent(Intent.ACTION_VIEW);
							intent.setData(Uri.fromFile(file));
							intent.putExtra("play","/sdcard/s022_snoopydance.swf");
							intent.setComponent(tolauch);
							startActivity(intent);
							
						}*/
						/*File file = new File("/sdcard/test2.mp4");
						Intent intent = new Intent(Intent.ACTION_VIEW);
						intent.setDataAndType(Uri.fromFile(file),"audio/*"); 
						startActivity(intent);*/
						
						Intent intent = new Intent();
			        	intent.setClass(MP_final_content.this, image.class);
			        	  
			        	startActivity(intent);
			        	MP_final_content.this.finish();
						//finish();
					}
				}
        )
        .setNegativeButton
        (
        		R.string.str_no,
        		new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						// TODO Auto-generated method stub
						//finish();
					}
				}
        )
        .show();
    }
    
  public void handle_ImageButton()
  {
	  mImageButton1 =(ImageButton) findViewById(R.id.myImageButton1);
      mImageButton2 =(ImageButton) findViewById(R.id.myImageButton2);
      mImageButton3 =(ImageButton) findViewById(R.id.myImageButton3);
      mImageButton4 =(ImageButton) findViewById(R.id.myImageButton4);
      mImageButton5 =(ImageButton) findViewById(R.id.myImageButton5);
  
      mImageButton1.setOnClickListener(new OnClickListener()
      {
        public void onClick(View v)
        {
          // TODO Auto-generated method stub
            setContentView(R.layout.a);
        }   
      }
      );
      mImageButton2.setOnClickListener(new OnClickListener()
      {
        public void onClick(View v)
        {
          // TODO Auto-generated method stub
      	  //setContentView(R.layout.b);
          Intent intent = new Intent();
      	  intent.setClass(MP_final_content.this, BrowsingCloset.class);
      	  
      	  startActivity(intent);
      	  MP_final_content.this.finish();
        }   
      }
      );
      mImageButton3.setOnClickListener(new OnClickListener()
      {
        public void onClick(View v)
        {
          // TODO Auto-generated method stub
        	Intent intent = new Intent();
        	intent.setClass(MP_final_content.this, Collocate.class);
        	  
        	startActivity(intent);
        	MP_final_content.this.finish();
      	  //setContentView(R.layout.c);
        }   
      }
      );
      mImageButton4.setOnClickListener(new OnClickListener()
      {
        public void onClick(View v)
        {
          // TODO Auto-generated method stub
      	  setContentView(R.layout.d);
        }   
      }
      );
      mImageButton5.setOnClickListener(new OnClickListener()
      {
        public void onClick(View v)
        {
          // TODO Auto-generated method stub
        	showDialogue("Leave Suit Yourself?");
      	  //setContentView(R.layout.e);
         }   
      }
      );
  }
  
  
  
}